﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AXImServer
{
    public interface IFilter { }

    /// <summary>
    /// 过滤器
    /// </summary>
    public class Filter : IFilter
    {
        public Object Key { get; set; }

        public Object Value { get; set; }

        public Object Operator { get; set; }
    }

    /// <summary>
    /// 顺序过滤器
    /// </summary>
    public class SequenceFilter : List<IFilter>, IFilter { }

    /// <summary>
    /// 选择过滤器
    /// </summary>
    public class SelectFilter : List<IFilter>, IFilter { }

    public interface IOrderBy { }

    public class OrderBy : IOrderBy
    {
        public Object Key { get; set; }

        public Object Operator { get; set; }
    }

    public class OrderByList : List<IOrderBy>, IOrderBy { }

    public interface IBusiness<T, PK>
    {
        bool Add(T t);

        int Remove(T t);

        int RemoveByFilter(IFilter filter);

        int RemoveByPK(PK pk);

        bool Update(T t);

        T Get(PK pk);

        T GetFirstByFilter(IFilter filter, IOrderBy orderby = null);

        IEnumerable<T> GetList(IEnumerable<PK> pks);

        IEnumerable<T> GetAll(IOrderBy orderby = null);

        IEnumerable<T> GetAllByFilter(IFilter filter, IOrderBy orderby = null);
    }
}
